package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * C端套餐控制器
 */
@RestController
@RequestMapping("/mobile")
@Slf4j
public class MobileSetMealController {
    @Autowired
    private SetMealService setMealService;

    //C端的体检预约查询列表  地址为:http://localhost:17080/mobile/setmeal/getSetmeal
    @GetMapping("/setmeal/getSetmeal")
    public Result getSetmeal() {
        log.info("[C端查询列表跑通]");
        List<Setmeal> list = setMealService.findAll();
        return new Result(true, MessageConst.ACTION_SUCCESS,list);
    }


    @GetMapping("/findById")
    public Result findById(Integer id){
        log.info("[根据id查找套餐]id:{}",id);
        Setmeal setmeal = setMealService.findById(id);
        return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
    }

    /**
     * 根据套餐id查询套餐详情
     * @param id
     * @return
     */
    @GetMapping("/setmeal/findById")
    public Result orderFindById(Integer id){
        log.info("[根据id查找套餐]id:{}",id);
        Setmeal setmeal = setMealService.findById(id);
        return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
    }



}
